home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PsL Monthly 1993 December
/
PSL Monthly Shareware CD-ROM (December 1993).iso
/
prgmming
/
dos
/
c
/
oopbstc.exe
/
OOPBASE.DOC
< prev
next >
Wrap
Text File
|
1991-08-22
|
12KB
|
476 lines
--------------------------------------------------------------------------
oopbase.doc
OOP Database routines
Interface Documentation
Silico-Magnetic Intelligence
24 Jean Lane
Chestnut Ridge, NY 10952
914 426-2610 FAX: 914 426-3152
--------------------------------------------------------------------------
Summary
The oopbase module is an object-oriented database library.
A record in the database consists of a key and a data part.
The two parts are separated by an internal character in the database.
The records are organized into a multi-level tree following ascii
sorting sequence. The combined size of key and data cannot exceed
Record_max which is defined in oopbase.d.
List of Functions
db_start - activate module
db_end - deactivate module
db_open - activate database object
db_close - destroy database object
db_create - create database
db_insert - add a record
db_read_key - read database by key
db_search - search database
db_go_to_first - set database pointer to beginning
db_go_to_last - set database pointer to end
db_read_next - read next record
db_read_previous - read_previous record
Notes
--------------------------------------------------------------------------
db_open
--------------------------------------------------------------------------
Function Creates a database object.
Syntax int db_open( char * file_name )
Arguments file_name - disk name of database
Remarks If creation succesful, memory is allocated for object,
file is opened, and a handle is returned.
Return value >=0 ok, handle is returned
Eof failed to create object
Limitations
See also db_close, db_create
Example if ( ( phone_base = db_open( "phones.db") ) == Eof )
ret = false;
--------------------------------------------------------------------------
db_close
--------------------------------------------------------------------------
Function Destroys object.
Syntax void db_close ( int handle)
Arguments handle - handle of object to be destroyed
Remarks Closes file, deallocates memory, releases handle.
Limitations
See also db_open
Example db_close( phone_base );
--------------------------------------------------------------------------
db_start
--------------------------------------------------------------------------
Function Allocates memory for module structure.
Syntax int db_start()
Arguments
Remarks Should be called at the beginning of the program.
Return value true: allocation is ok, module can be used
false: failure to allocate, module is not active
Limitations
See also db_end
Example if ( not db_start() )
ret = Eof;
--------------------------------------------------------------------------
db_end
--------------------------------------------------------------------------
Function Deallocates memory of module structure.
Syntax void db_end()
Arguments
Remarks Should be called at the end of the program.
Return value
Limitations
See also db_start
Example db_end();
--------------------------------------------------------------------------
db_create
--------------------------------------------------------------------------
Function Create database
Syntax int db_create( char *file_name, char *database_title)
Arguments file_name - database diskfile name
database_title - diskfile header information
Remarks Creates a new database.
Use it only once!
Open must be used to access the created database.
Return value true - db created ok
false - io failure
Limitations
See also db_open
Example db_create( "phones.db", "Customer telephone numbers");
--------------------------------------------------------------------------
db_insert
--------------------------------------------------------------------------
Function Insert record
Syntax int db_insert( int handle, char *key, char *data)
Arguments key - key string
data - data string
Remarks Inserts new record into database.
Combined size cannot exceed Record_max default.
Return value Eof - io failure
false - duplicate
true - inserted ok
Limitations
See also
Example db_insert( phone_base, "Jane Gizzy", "212 543-2344");
--------------------------------------------------------------------------
db_update
--------------------------------------------------------------------------
Function Update record
Syntax int db_update( int handle, char *key, char *new_data)
Arguments key of current record
new_data to replace current data
Remarks Updates record with key by replacing current data with
new data.
If record does not exist, it is inserted.
Return value true - ok
false - io failure
Limitations
See also db_insert
Example db_update( phone_base, "Jane Gizzy", "202 345-7777");
--------------------------------------------------------------------------
db_delete
--------------------------------------------------------------------------
Function Delete record
Syntax int db_delete( int handle, char *key)
Arguments key - key of record to be deleted
Remarks Deletes record from database.
Return value Eof - io failure
false - not found
true - record deleted
Limitations
See also db_search
Example db_delete( phone_base, "Jane Gizzy");
--------------------------------------------------------------------------
db_go_to_first
--------------------------------------------------------------------------
Function Position to head of database
Syntax void db_go_to_first( int handle)
Remarks Positions to first record in ascii ascending sort order.
Limitations
See also db_read_next
Example db_go_to_first( phone_base);
--------------------------------------------------------------------------
db_go_to_last
--------------------------------------------------------------------------
Function Position to end of database
Syntax void db_go_to_last( int handle)
Remarks Positions to last record in ascii ascending order.
Limitations
See also db_read_previous
Example db_go_to_last (phone_base);
--------------------------------------------------------------------------
db_read_next
--------------------------------------------------------------------------
Function Read next record
Syntax int db_read_next( int handle, char *key, char *data)
Arguments key - key of next record
data - data of next record
Remarks Reads next record in database.
Returns record key and data.
Return value Eof - if at end of database
true - otherwise
Limitations
See also db_go_to_first
Example while ( db_read_next(phone_base, name, phone) EQ true)
printf("\n %s \t-- %s", name, phone);
--------------------------------------------------------------------------
db_read_previous
--------------------------------------------------------------------------
Function Read previous record
Syntax int db_read_previous( int handle, char *key, char *data)
Arguments key - key of next record
data - data of next record
Remarks Reads previous record in database.
Returns record key and data.
Return value Eof - if at head of database
true - otherwise
Limit